#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.service.convert;

import com.github.pagehelper.PageInfo;
import com.google.common.base.Converter;
import ${package}.pojo.Demo;
import ${package}.pojo.vo.DemoOutputVo;
import org.springframework.lang.NonNull;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author qingchang.tang
 * @date 2020/7/24 18:53
 */
public class DemoPageInfoOutputVoConverter extends Converter<PageInfo<Demo>, PageInfo<DemoOutputVo>> {
    @Override
    protected PageInfo<DemoOutputVo> doForward(@NonNull PageInfo<Demo> demoPageInfo) {

        List<Demo> data = demoPageInfo.getList();
        if (CollectionUtils.isEmpty(data)) {
            return new PageInfo<>();
        }

        List<DemoOutputVo> voList = new ArrayList<>();
        data.forEach(demo -> {
            DemoOutputVo vo = new DemoOutputVoConverter().convert(demo);
            voList.add(vo);
        });

        return new PageInfo<>(voList);
    }

    @Override
    protected PageInfo<Demo> doBackward(@NonNull PageInfo<DemoOutputVo> demoOutputVoPageInfo) {
        throw new UnsupportedOperationException("do backward unsupported");
    }
}
